package com.qdlc.p2p.common.constant;

import org.apache.commons.lang3.StringUtils;

/**
 * 外部业务码
 * <p/>
 * 投资业务：代收投资[1001]和代付借款[2001]
 * 还款业务：代收还款[1002]和代付（本金/收益）[2002]
 * 注意：相同业务的代收代付外部业务码必须配套使用。
 *
 * @author linya 2015-12-25
 */
public enum TradeCode {

    C1001(1001, "代收投资金"),
    C1002(1002, "代收还款金"),
    C1003(1003, "代收红包"),
    C1004(1004, "代收还款金(本金+利息)"),
    C1005(1005, "代收加息金(加息)"),
    C1006(1006, "抽奖代收"),
	C1007(1007, "满标复审代收"),
	C1008(1008, "提现手续费代收"),
	C1009(1009, "代收体验金利息"),
	C1010(1010, "代收酒券"),
    C1011(1011, "代收投资奖励"),
    C2001(2001, "代付借款金"),
    C2002(2002, "代付（本金/收益）金"),
    C2003(2003, "代付红包"),
    C2004(2004, "代付还款金(本金+利息)"),
    C2005(2005, "代付加息金(加息)"),
    C2006(2006, "抽奖代付"),
	C2007(2007, "满标复审代付"),
	C2008(2008, "提现手续费代付"),
    C2009(2009, "代付体验金利息"),
    C2010(2010, "代付酒券"),
    C2011(2011, "代付投资奖励");

    int code;
    String name;

    TradeCode(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static TradeCode getTradeCodeByType(String tradeType) {
        if (StringUtils.isBlank(tradeType)) {
            return C1001;
        }
        for (TradeCode entry : TradeCode.values()) {
            if (String.valueOf(entry.code).equals(tradeType)) {
                return entry;
            }
        }
        return C1001;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    @Override
    public String toString() {
        return this.code + "";
    }

}
